home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / getOptionBox.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  25.0 KB  |  926 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  3 April 1997
  22. //  Author:         bwk
  23. //
  24. //  Description:
  25. //      Implement and provide access to the common elements of the 
  26. //        option box window.
  27. //
  28.  
  29. //    NOTE:
  30. //        If you plan on modifying this file be aware that there are
  31. //        still the following option boxes that rely on the incredibly 
  32. //        old getStandardWindow() interface.
  33. //
  34. //        As of Maya3.0 28jan00:
  35. //            performShowResults.mel      Graph Editor Panel: View->Show Results[]
  36. //            performBakeResults.mel      Graph Editor Panel: Curves->Bake Channel[]
  37. //            performSimplify.mel         Graph Editor Panel: Curves->Simplify Curve[]
  38. //            performPlayblast.mel        Window->Playblast...[]
  39. //            performDetachSkin.mel       Skin->Detach Skin[]
  40. //            performCutKeyArgList.mel    Edit->Keys->Cut Keys[]
  41. //            performCopyKeyArgList.mel   Edit->Keys->Copy Keys[]
  42. //            performPasteKeyArgList.mel  Edit->Keys->Paste Keys[]
  43. //            performClearKeyArgList.mel  Edit->Keys->Delete Keys[]
  44. //            performScaleKeyArgList.mel  Edit->Keys->Scale Keys[]
  45. //            performSnapKeyArgList.mel   Edit->Keys->Snap Keys[]
  46. //            fileOptions.mel             File->Open Scene...[]
  47. //                                        File->Save Scene As...[]
  48. //                                        File->Import...[]
  49. //                                        File->Export All...[]
  50. //                                        File->Export Selection...[]
  51. //                                        File->Create Reference...[]
  52. //
  53. //        getStandardWindow() does end up calling into getOptionBox(),
  54. //        however the set up of the UI for these option boxes is a little
  55. //        different so be sure to test that these options boxes still
  56. //        look and work as expected.
  57. //
  58. //        -bwk 28jan00
  59. //
  60.  
  61. //
  62. //  Procedure Name:
  63. //      updateOptionBoxEditMenu
  64. //
  65. //  Description:
  66. //      Update the option box's Edit menu.
  67. //
  68. //        This situation arises when the Option Box is already created and
  69. //        the user selects another command's or tool's option box menu item.
  70. //
  71. //        Take this opportunity to update the enable state of the Edit menu
  72. //        items.
  73. //
  74. //  Input Arguments:
  75. //      The option box window name.
  76. //
  77. //  Return Value:
  78. //      None
  79. //
  80. proc updateOptionBoxEditMenu(string $parent) {
  81.  
  82.     //    Global variables...
  83.     //
  84.     global string $gOptionBoxActionToolItem;
  85.     global string $gOptionBoxActionToolItemCB;
  86.  
  87.     global string $gOptionBoxEditMenu;
  88.     global string $gOptionBoxEditMenuToolItem;
  89.     global string $gOptionBoxEditMenuActionItem;
  90.     
  91.     //    Make sure the menu and its menu items exist before trying to
  92.     //    edit them.
  93.     //
  94.     if (!`menu -exists $gOptionBoxEditMenu` ||
  95.         !`menuItem -exists $gOptionBoxEditMenuToolItem` ||
  96.         !`menuItem -exists $gOptionBoxEditMenuActionItem`) {
  97.         return;
  98.     }
  99.     
  100.     if ("" != $gOptionBoxActionToolItem) {
  101.         //
  102.         //    Enable the menu and items, also attach the appropriate commands
  103.         //    to the menu items.
  104.         //
  105.         menuItem -edit -enable true
  106.             -radioButton `optionVar -q $gOptionBoxActionToolItem`
  107.             -command ("optionVar -iv " + $gOptionBoxActionToolItem + " 1; " +
  108.                 $gOptionBoxActionToolItemCB)
  109.             $gOptionBoxEditMenuToolItem;
  110.         menuItem -edit -enable true
  111.             -radioButton (!`optionVar -q $gOptionBoxActionToolItem`)
  112.             -command ("optionVar -iv " + $gOptionBoxActionToolItem + " 0; " +
  113.                 $gOptionBoxActionToolItemCB)
  114.             $gOptionBoxEditMenuActionItem;
  115.         
  116.         $gOptionBoxActionToolItem = "";
  117.         
  118.     } else {
  119.         //
  120.         //    Disable the menu and items.
  121.         //
  122.         menuItem -edit -enable false $gOptionBoxEditMenuToolItem;
  123.         menuItem -edit -enable false $gOptionBoxEditMenuActionItem;
  124.     }
  125. }
  126.  
  127. //
  128. //  Procedure Name:
  129. //      updateOptionBox
  130. //
  131. //  Description:
  132. //      Update the option box content (controls, menus, etc...) to reflect
  133. //        the new command/tool.
  134. //
  135. //        This situation arises when the Option Box is already created and
  136. //        the user selects another command's or tool's option box menu item.
  137. //
  138. //        Take this opportunity to update (for example enable/disable controls
  139. //        or menu items).
  140. //
  141. //  Input Arguments:
  142. //      The option box window name.
  143. //
  144. //  Return Value:
  145. //      None
  146. //
  147. proc updateOptionBox(string $optionBox)
  148. {
  149.     //    No controls to update.  Just update the enable state of the "Edit"
  150.     //    menu.
  151.     //
  152.     updateOptionBoxEditMenu($optionBox);
  153. }
  154.  
  155. //
  156. //  Procedure Name:
  157. //      createOptionBoxEditMenu
  158. //
  159. //  Description:
  160. //      Creates the option box 'Edit' menu.
  161. //
  162. //  Input Arguments:
  163. //      The option box window name.
  164. //
  165. //  Return Value:
  166. //      None
  167. //
  168. proc createOptionBoxEditMenu(string $parent) {
  169.  
  170.     //    Global variables...
  171.     //
  172.     global string $gOptionBoxEditMenu;
  173.     global string $gOptionBoxEditMenuSaveItem;
  174.     global string $gOptionBoxEditMenuResetItem;
  175.     global string $gOptionBoxEditMenuToolItem;
  176.     global string $gOptionBoxEditMenuActionItem;
  177.     
  178.     //    For mac: 
  179.     //    attach a menuBarLayout to a window, which wants menus
  180.     if (!`about -mac`) {
  181.         setParent $parent;
  182.     }
  183.  
  184.     //    Create the 'Edit' menu.
  185.     //
  186.     $gOptionBoxEditMenu = `menu -label "Edit"`;
  187.  
  188.     //    Create the menu items.
  189.     //
  190.     $gOptionBoxEditMenuSaveItem = `menuItem -label "Save Settings"`;
  191.     $gOptionBoxEditMenuResetItem = `menuItem -label "Reset Settings"`;
  192.     menuItem -divider true;
  193.  
  194.     radioMenuItemCollection;
  195.     $gOptionBoxEditMenuToolItem = `menuItem 
  196.         -radioButton true -label "As Tool"`;
  197.     $gOptionBoxEditMenuActionItem = `menuItem 
  198.         -radioButton true -label "As Action"`;
  199.  
  200.     updateOptionBoxEditMenu($parent);
  201. }
  202.  
  203. //
  204. //  Procedure Name:
  205. //      createOptionBoxHelpMenu
  206. //
  207. //  Description:
  208. //      Creates the option box 'Help' menu.
  209. //
  210. //  Input Arguments:
  211. //      The option box window name.
  212. //
  213. //  Return Value:
  214. //      None
  215. //
  216. proc createOptionBoxHelpMenu(string $parent) {
  217.  
  218.     //    Global variables...
  219.     //
  220.     global string $gOptionBoxHelpItem;
  221.  
  222.     //    For mac: 
  223.     //    attach a menuBarLayout to a window, which wants menus
  224.     if (!`about -mac`) {
  225.         setParent $parent;
  226.     }
  227.  
  228.     //    Create the 'Help' menu.  Be sure to indicate that this is
  229.     //    the 'Help' menu so that it appears right justified in the
  230.     //    menu bar.
  231.     //
  232.     menu -label "Help" -helpMenu 1;
  233.  
  234.     //    Create the 'Help' menu items.
  235.     //
  236.     $gOptionBoxHelpItem = `menuItem -label "No Help Currently Available" -enableCommandRepeat false`;
  237. }
  238.  
  239. //
  240. //  Procedure Name:
  241. //      createOptionBoxMenus
  242. //
  243. //  Description:
  244. //      Creates the option box menus.
  245. //
  246. //  Input Arguments:
  247. //      The option box window name.
  248. //
  249. //  Return Value:
  250. //      None.
  251. //
  252. proc createOptionBoxMenus(string $parent) {
  253.  
  254.     //    Create the option box menus.  For additional menus add
  255.     //    similar procedure calls, for example:
  256.     //
  257.     //    createOptionBoxFileMenu($parent);
  258.     //    createOptionBoxEditMenu($parent);
  259.     //
  260.     createOptionBoxEditMenu($parent);
  261.     createOptionBoxHelpMenu($parent);
  262. }
  263.  
  264. //
  265. //  Procedure Name:
  266. //      createOptionBox
  267. //
  268. //  Description:
  269. //      Creates the common UI elements for the option box window.
  270. //
  271. //  Input Arguments:
  272. //      None.
  273. //
  274. //  Return Value:
  275. //      The name of the option box window.
  276. //
  277. proc string createOptionBox() {
  278.  
  279.     //    Global variables...
  280.     //
  281.     global string $gOptionBoxTabLayout;
  282.     global string $gOptionBoxApplyAndCloseBtn;
  283.     global string $gOptionBoxApplyBtn;
  284.     global string $gOptionBoxResetBtn;
  285.     global string $gOptionBoxCloseBtn;
  286.     global string $gOptionBoxSaveBtn;
  287.  
  288.     //    Create the option box window.
  289.     //
  290.     string $optionBox = `window -menuBar 1 -iconName "Options" -widthHeight 525 350 OptionBoxWindow`;
  291.  
  292.     //    Create the menu bar.
  293.     //
  294.     createOptionBoxMenus($optionBox);
  295.  
  296.     //    Create the common UI elements.
  297.     //
  298.     string $form = `formLayout`;
  299.  
  300.     //    To reduce flicker when changing the option box contents
  301.     //    use a tab layout.  Create new UI in the hidden tab, leaving
  302.     //    the current option box contents visible until the new UI is
  303.     //    created.  When creation of the new UI is complete then the 
  304.     //    hidden tab will become the current one and the old option box
  305.     //    UI will be deleted.
  306.     //
  307.     $gOptionBoxTabLayout = `tabLayout -tabsVisible 0`;
  308.  
  309.         //    Create two children for the tab layout.
  310.         //    
  311.         formLayout;
  312.             setParent ..;
  313.         formLayout;
  314.             setParent ..;
  315.         setParent ..;
  316.  
  317.     //    Create a layout containing the common option box buttons.
  318.     //    Force the buttons to have a common width, this will not only
  319.     //    look better but also allow the buttons to be centred in the
  320.     //    window.
  321.     //
  322.     string $buttonForm = `formLayout`;
  323.     int $buttonHeight = 26;
  324.     $gOptionBoxApplyAndCloseBtn = `button -recomputeSize 0 -height $buttonHeight`;
  325.     $gOptionBoxApplyBtn = `button -recomputeSize 0 -height $buttonHeight`;
  326.     $gOptionBoxResetBtn = `button -recomputeSize 0 -height $buttonHeight`;
  327.     $gOptionBoxCloseBtn = `button -recomputeSize 0 -height $buttonHeight`;
  328.     $gOptionBoxSaveBtn = `button -recomputeSize 0 -height $buttonHeight`;
  329.  
  330.     //    Apply attachments to the buttons so that they appear centred 
  331.     //    in the window.
  332.     //
  333.     int $space = 4; // Space between buttons.
  334.     formLayout -edit
  335.         -numberOfDivisions 100
  336.  
  337.         -attachForm     $gOptionBoxApplyAndCloseBtn "top"    0
  338.         -attachForm     $gOptionBoxApplyAndCloseBtn "left"     0
  339.         -attachForm     $gOptionBoxApplyAndCloseBtn "bottom" 0
  340.         -attachPosition $gOptionBoxApplyAndCloseBtn "right"  ($space/2) 33
  341.  
  342.         -attachForm     $gOptionBoxApplyBtn         "top"    0
  343.         -attachPosition $gOptionBoxApplyBtn         "left"     ($space/2) 33
  344.         -attachForm     $gOptionBoxApplyBtn         "bottom" 0
  345.         -attachPosition $gOptionBoxApplyBtn         "right"  ($space/2) 67
  346.  
  347.         -attachForm     $gOptionBoxCloseBtn         "top"    0
  348.         -attachPosition $gOptionBoxCloseBtn         "left"   ($space/2) 67
  349.         -attachForm     $gOptionBoxCloseBtn         "bottom" 0
  350.         -attachForm     $gOptionBoxCloseBtn         "right"  0
  351.         $buttonForm;
  352.  
  353.     //    Apply attachments to the tab layout containing the option box
  354.     //    UI, the separator and the button layout.
  355.     //
  356.     $space = 5; // Space between tabs, separator and button layout.
  357.     formLayout -edit
  358.         -attachForm    $gOptionBoxTabLayout "top"    0
  359.         -attachForm    $gOptionBoxTabLayout "left"   0
  360.         -attachControl $gOptionBoxTabLayout "bottom" $space $buttonForm
  361.         -attachForm    $gOptionBoxTabLayout "right"  0
  362.  
  363.         -attachNone    $buttonForm          "top"
  364.         -attachForm    $buttonForm          "left"   $space
  365.         -attachForm    $buttonForm          "bottom" $space
  366.         -attachForm    $buttonForm          "right"  $space
  367.         $form;
  368.  
  369.     return $optionBox;
  370. }
  371.  
  372. //
  373. //  Procedure Name:
  374. //      getOptionBox
  375. //
  376. //  Description:
  377. //      Create, if necessary, and return the option box window.
  378. //        More specifically, this procedure returns the name of the 
  379. //        control layout that additional UI may be added to for the
  380. //        purpose of customizing the option box.
  381. //
  382. //  Input Arguments:
  383. //      None.
  384. //
  385. //  Return Value:
  386. //      The name of control layout to which additional UI may be
  387. //        added.
  388. //
  389. global proc string getOptionBox() {
  390.  
  391.     //    Global variables...
  392.     //
  393.     global string $gOptionBox;
  394.     global string $gOptionBoxTabLayout;
  395.     global string $gOptionBoxApplyAndCloseBtn;
  396.     global string $gOptionBoxApplyBtn;
  397.     global string $gOptionBoxResetBtn;
  398.     global string $gOptionBoxCloseBtn;
  399.     global string $gOptionBoxSaveBtn;
  400.  
  401.     //    Create the option box window if necessary.
  402.     //
  403.     if (`window -exists $gOptionBox`) {
  404.  
  405.         //    Option box already exists.  Update the option box content 
  406.         //    (controls and menus) to reflect the new command/tool.
  407.         //
  408.         updateOptionBox($gOptionBox);
  409.  
  410.     } else {
  411.         
  412.         //    Option box doesn't exist yet, create it.
  413.         //
  414.         $gOptionBox = createOptionBox(); 
  415.     }
  416.  
  417.     //    Reset the default state of the buttons.
  418.     //
  419.     button -edit -enable 1 -visible 1 -label "" -command ("") 
  420.         $gOptionBoxApplyAndCloseBtn;
  421.     button -edit -enable 1 -visible 1 -label "Apply" $gOptionBoxApplyBtn;
  422.     button -edit -enable 1 -visible 0 -label "Reset" $gOptionBoxResetBtn;
  423.     button -edit -enable 1 -visible 1 -label "Close" 
  424.         -command "hideOptionBox" $gOptionBoxCloseBtn;
  425.     button -edit -enable 1 -visible 0 -label "Save" $gOptionBoxSaveBtn;
  426.  
  427.     //    Remove any dim conditions set on these buttons.
  428.     //
  429.     dimWhen -clear $gOptionBoxApplyAndCloseBtn;
  430.     dimWhen -clear $gOptionBoxApplyBtn;
  431.     dimWhen -clear $gOptionBoxResetBtn;
  432.     dimWhen -clear $gOptionBoxCloseBtn;
  433.     dimWhen -clear $gOptionBoxSaveBtn;
  434.  
  435.     //    Get the children of the tab layout.
  436.     //
  437.     string $tab[] = `tabLayout -query -childArray $gOptionBoxTabLayout`;
  438.     string $returnTab = "";
  439.  
  440.     //    Determine the hidden tab.  Return the hidden tab so that the user
  441.     //    does not see the option box UI being created.  Once the UI is created
  442.     //    the hidden tab will become the active one.
  443.     //
  444.     int $currentTabIndex = `tabLayout -query -selectTabIndex $gOptionBoxTabLayout`;
  445.  
  446.     //    Be sure to constuct the layout's long name to avoid a possible
  447.     //    naming conflict.
  448.     //
  449.     if ($currentTabIndex == 1) {
  450.         $returnTab = ($gOptionBoxTabLayout + "|" + $tab[1]);
  451.     } else {
  452.         $returnTab = ($gOptionBoxTabLayout + "|" + $tab[0]);
  453.     }
  454.  
  455.     return $returnTab;
  456. }
  457.  
  458. //
  459. //  Procedure Name:
  460. //      showOptionBox
  461. //
  462. //  Description:
  463. //      Make the option box visible to the user.
  464. //
  465. //  Input Arguments:
  466. //      None.
  467. //
  468. //  Return Value:
  469. //      None.
  470. //
  471. global proc showOptionBox() {
  472.  
  473.     //    Global variables...
  474.     //
  475.     global string $gOptionBox;
  476.     global string $gOptionBoxTabLayout;
  477.     global string $gOptionBoxApplyAndCloseBtn;
  478.     global string $gOptionBoxApplyBtn;
  479.     global string $gOptionBoxSaveBtn;
  480.     global string $gOptionBoxResetBtn;
  481.     global string $gOptionBoxEditMenuSaveItem;
  482.     global string $gOptionBoxEditMenuResetItem;
  483.  
  484.     if (`window -exists $gOptionBox`) {
  485.  
  486.         //    Get the children of the tab layout.
  487.         //
  488.         string $tab[] = `tabLayout -query -childArray $gOptionBoxTabLayout`;
  489.  
  490.         //    Determine the hidden tab containing the new option box UI, and
  491.         //    the current tab whose UI is no longer required and may be deleted.
  492.         //
  493.         int $currentTabIndex = `tabLayout -query -selectTabIndex $gOptionBoxTabLayout`;
  494.  
  495.         //    Construct the long name of the tabs to ensure there is no naming
  496.         //    conflict.
  497.         //
  498.         string $newTab = ($gOptionBoxTabLayout + "|");
  499.         string $oldTab = ($gOptionBoxTabLayout + "|");
  500.         if ($currentTabIndex == 1) {
  501.             $oldTab = $oldTab + $tab[0];
  502.             $newTab = $newTab + $tab[1];
  503.         } else {
  504.             $oldTab = $oldTab + $tab[1];
  505.             $newTab = $newTab + $tab[0];
  506.         }
  507.  
  508.         //    Get the child of the hidden tab and apply the attachments...
  509.         //
  510.         string $contents[] = `formLayout -query -childArray $newTab`;
  511.         formLayout -edit
  512.             -attachForm $contents[0] "top"    0
  513.             -attachForm $contents[0] "left"   0
  514.             -attachForm $contents[0] "bottom" 0
  515.             -attachForm $contents[0] "right"  0
  516.             $newTab;
  517.  
  518.         //    Make visible the tab containing the new option box UI.
  519.         //
  520.         tabLayout -edit -selectTab $newTab $gOptionBoxTabLayout;
  521.  
  522.         //    Now delete the contents, if any, of the old tab...
  523.         //
  524.         if (`formLayout -query -numberOfChildren $oldTab` > 0) {
  525.             string $child[] = `formLayout -query -childArray $oldTab`;
  526.             int $count = `formLayout -query -numberOfChildren $oldTab`;
  527.             int $index;
  528.             for ($index = 0; $index < $count; $index++) {
  529.                 deleteUI ($oldTab + "|" + $child[$index]);
  530.             }
  531.         }
  532.  
  533.         //    Check the label attached to the "Apply & Close" button.
  534.         //    If it is empty then apply a default label.  Otherwise,
  535.         //    leave it alone because that means it was customized by
  536.         //    a specific option box.
  537.         //
  538.         //    Assume that if someone has actually customized the 
  539.         //    label of the "Apply and Close" button then they also
  540.         //    made sure that the "Apply" button says something
  541.         //    appropriate.
  542.         //
  543.         string $label = `button -query -label $gOptionBoxApplyAndCloseBtn`;
  544.         if ("" == $label) {
  545.             //
  546.             //    The default label of the "Apply and Close" button will
  547.             //    be the label for the "Apply" button.  The "Apply"
  548.             //    button will then be set to say "Apply".
  549.             //
  550.             //    If the "Apply" button already says "Apply" then the
  551.             //    "Apply and Close" will say "Apply and Close".
  552.             //
  553.             $label = `button -query -label $gOptionBoxApplyBtn`;
  554.             if ("Apply" == $label) {
  555.                 button -edit -label "Apply and Close" $gOptionBoxApplyAndCloseBtn;
  556.             } else {
  557.                 button -edit -label "Apply" $gOptionBoxApplyBtn;
  558.                 button -edit -label $label $gOptionBoxApplyAndCloseBtn;
  559.             }
  560.         }
  561.  
  562.         //    Check the command attached to the "Apply & Close" button.
  563.         //    If it is empty then apply a default action.  Otherwise,
  564.         //    leave it alone because that means it was customized by
  565.         //    a specific option box.
  566.         //
  567.         string $command = `button -query -command $gOptionBoxApplyAndCloseBtn`;
  568.         if ("" == $command) {
  569.             //
  570.             //    The default action will consist of the command attached
  571.             //    to the "Apply" button plus the action to hide the 
  572.             //    option box.
  573.             //
  574.             $command = `button -query -command $gOptionBoxApplyBtn`;
  575.             $command += ("; hideOptionBox");
  576.             button -edit -command $command $gOptionBoxApplyAndCloseBtn;
  577.         }
  578.  
  579.         //    For 3.0 we removed the "Save" and "Reset" buttons and replaced
  580.         //    them with menu items.
  581.         //
  582.         //    Note that we didn't want to change every option box script 
  583.         //    so the buttons are still being created and the functions that
  584.         //    access them still exist.  The user however cannot see the
  585.         //    buttons.
  586.         //
  587.         //    To solve the problem, simply query the commands attached
  588.         //    to the buttons and apply them to the corresponding
  589.         //    menu items.
  590.         //
  591.         $command = `button -query -command $gOptionBoxSaveBtn`;
  592.         //
  593.         //    Bug fix #131958. We don't want the "Save Settings" menu item
  594.         //    closing the window like the "Save Settings" button used to do.
  595.         //    Remove the call to hide the option box.
  596.         //
  597.         $command = `substitute "hideOptionBox" $command "fauxHideOptionBox"`;
  598.         menuItem -edit -command $command $gOptionBoxEditMenuSaveItem;
  599.  
  600.         $command = `button -query -command $gOptionBoxResetBtn`;
  601.         menuItem -edit -command $command $gOptionBoxEditMenuResetItem;
  602.  
  603.         showWindow $gOptionBox;
  604.  
  605.     } else {
  606.         error "Option Box window does not exist.";
  607.     }
  608. }
  609.  
  610. //
  611. //  Procedure Name:
  612. //      hideOptionBox
  613. //
  614. //  Description:
  615. //      Make the option box invisible to the user.  By default, this
  616. //        procedure is attached to the option box's 'Close' button.  If an
  617. //        alternate action is attached to the 'Close' button then be sure
  618. //        to call this procedure explicity so that the option box is 
  619. //        dismissed properly.
  620. //
  621. //  Input Arguments:
  622. //      None.
  623. //
  624. //  Return Value:
  625. //      None.
  626. //
  627. global proc hideOptionBox() {
  628.  
  629.     //    Global variables...
  630.     //
  631.     global string $gOptionBox;
  632.  
  633.     if (`window -exists $gOptionBox`) {
  634.     
  635.         //    Currently, the option box window is made invisible by
  636.         //    deleting it.
  637.         //
  638.         evalDeferred ("if (`window -exists " + $gOptionBox + "`) deleteUI -window " + $gOptionBox);
  639.     }
  640. }
  641.  
  642. //
  643. //  Procedure Name:
  644. //      fauxHideOptionBox
  645. //
  646. //  Description:
  647. //      Do nothing. This proc exists so that we can 
  648. //        substitute "hideOptionBox" with "fauxHideOptionBox" in
  649. //        commands attached to the "Save Settings" menu item.
  650. //
  651. //        See bug #131958.
  652. //
  653. //  Input Arguments:
  654. //      None.
  655. //
  656. //  Return Value:
  657. //      None.
  658. //
  659. global proc fauxHideOptionBox() {
  660.     //
  661.     //    Do absolutely nothing.
  662.     //
  663. }
  664.  
  665. //
  666. //  Procedure Name:
  667. //      setOptionBoxTitle
  668. //
  669. //  Description:
  670. //      Set the title of the option box window.
  671. //
  672. //  Input Arguments:
  673. //      The title of the option box window.
  674. //
  675. //  Return Value:
  676. //      None.
  677. //
  678. global proc setOptionBoxTitle(string $title) {
  679.  
  680.     //    Global variables...
  681.     //
  682.     global string $gOptionBox;
  683.  
  684.     if (`window -exists $gOptionBox`) {
  685.  
  686.         //    Set the title of the option box window.
  687.         //
  688.         window -edit -title $title $gOptionBox;
  689.  
  690.     } else {
  691.         error "Option Box window does not exist.";
  692.     }
  693. }
  694.  
  695. //
  696. //  Procedure Name:
  697. //      getOptionBoxHelpMenuItem
  698. //
  699. //  Description:
  700. //      Return the name of the option box's 'Help' menu item.
  701. //
  702. //  Input Arguments: 
  703. //      None.
  704. //
  705. //  Return Value:
  706. //      The name of the option box's 'Help' menu item.
  707. //
  708. global proc string getOptionBoxHelpItem() {
  709.  
  710.     //    Global variables...
  711.     //
  712.     global string $gOptionBoxHelpItem;
  713.  
  714.     if (`menuItem -exists $gOptionBoxHelpItem`) {
  715.     } else {
  716.         error "Option Box window does not exist.";
  717.     }
  718.  
  719.     return $gOptionBoxHelpItem;
  720. }
  721.  
  722. //
  723. //  Procedure Name:
  724. //      setOptionBoxCommandName
  725. //
  726. //  Description:
  727. //      Set the command name of the option box window.  The command name
  728. //        is required to set up some common option box behaviour, for 
  729. //        example the label of the help menu item.
  730. //
  731. //    Note:
  732. //        If setOptionBoxHelpTag() is used then this method has
  733. //        no effect.
  734. //
  735. //  Input Arguments:
  736. //      The name of the command.
  737. //
  738. //  Return Value:
  739. //      None.
  740. //
  741. global proc setOptionBoxCommandName(string $commandName) {
  742.  
  743.     string $helpItem = getOptionBoxHelpItem();
  744.     menuItem -edit
  745.         -label ("Help with " + $commandName)
  746.         -command ("help -doc " + $commandName)
  747.         $helpItem;
  748. }
  749.  
  750. //
  751. //  Procedure Name:
  752. //      setOptionBoxHelpTag
  753. //
  754. //  Description:
  755. //      Set the help tag to use to look up the correct documentation
  756. //        page for this option box.  The text string in the help menu
  757. //        will be the Option Box title.  If this is set then the command
  758. //         in setOptionBoxCommandName() has no effect.
  759. //
  760. //  Input Arguments:
  761. //      The name of the help tag.
  762. //
  763. //  Return Value:
  764. //      None.
  765. //
  766. global proc setOptionBoxHelpTag(string $helpTag) {
  767.  
  768.     global string $gOptionBox;
  769.     if (`window -exists $gOptionBox`) {
  770.  
  771.         //    Get the title of the option box window to use for help.
  772.         //
  773.         string $title = `window -query -title $gOptionBox`;
  774.         string $helpItem = getOptionBoxHelpItem();
  775.         if ($helpTag != "") {
  776.             menuItem -edit
  777.                 -label ("Help on " + $title + "...")
  778.                 -command ("showHelp " + $helpTag)
  779.                 $helpItem;
  780.         } else {
  781.             menuItem -edit
  782.                 -label "No Help Currently Available"
  783.                 -command ""
  784.                 $helpItem;
  785.         }
  786.     } else {
  787.         error "Option Box window does not exist.";
  788.     }
  789. }
  790.  
  791. //
  792. //  Procedure Name:
  793. //      getOptionBoxApplyAndCloseBtn
  794. //
  795. //  Description:
  796. //      Return the name of the option box's 'Apply & Close' button.
  797. //
  798. //  Input Arguments: 
  799. //      None.
  800. //
  801. //  Return Value:
  802. //      The name of the option box's 'Apply & Close' button.
  803. //
  804. global proc string getOptionBoxApplyAndCloseBtn() {
  805.  
  806.     //    Global variables...
  807.     //
  808.     global string $gOptionBoxApplyAndCloseBtn;
  809.  
  810.     if (`button -exists $gOptionBoxApplyAndCloseBtn`) {
  811.     } else {
  812.         error "Option Box window does not exist.";
  813.     }
  814.  
  815.     return $gOptionBoxApplyAndCloseBtn;
  816. }
  817.  
  818. //
  819. //  Procedure Name:
  820. //      getOptionBoxApplyBtn
  821. //
  822. //  Description:
  823. //      Return the name of the option box's 'Apply' button.
  824. //
  825. //  Input Arguments: 
  826. //      None.
  827. //
  828. //  Return Value:
  829. //      The name of the option box's 'Apply' button.
  830. //
  831. global proc string getOptionBoxApplyBtn() {
  832.  
  833.     //    Global variables...
  834.     //
  835.     global string $gOptionBoxApplyBtn;
  836.  
  837.     if (`button -exists $gOptionBoxApplyBtn`) {
  838.     } else {
  839.         error "Option Box window does not exist.";
  840.     }
  841.  
  842.     return $gOptionBoxApplyBtn;
  843. }
  844.  
  845. //
  846. //  Procedure Name:
  847. //      getOptionBoxResetBtn
  848. //
  849. //  Description:
  850. //      Return the name of the option box's 'Reset' button.
  851. //
  852. //  Input Arguments: 
  853. //      None.
  854. //
  855. //  Return Value:
  856. //      The name of the option box's 'Reset' button.
  857. //
  858. global proc string getOptionBoxResetBtn() {
  859.  
  860.     //    Global variables...
  861.     //
  862.     global string $gOptionBoxResetBtn;
  863.  
  864.     if (`button -exists $gOptionBoxResetBtn`) {
  865.     } else {
  866.         error "Option Box window does not exist.";
  867.     }
  868.  
  869.     return $gOptionBoxResetBtn;
  870. }
  871.  
  872. //
  873. //  Procedure Name:
  874. //      getOptionBoxCloseBtn
  875. //
  876. //  Description:
  877. //      Return the name of the option box's 'Close' button.
  878. //
  879. //  Input Arguments: 
  880. //      None.
  881. //
  882. //  Return Value:
  883. //      The name of the option box's 'Close' button.
  884. //
  885. global proc string getOptionBoxCloseBtn() {
  886.  
  887.     //    Global variables...
  888.     //
  889.     global string $gOptionBoxCloseBtn;
  890.  
  891.     if (`button -exists $gOptionBoxCloseBtn`) {
  892.     } else {
  893.         error "Option Box window does not exist.";
  894.     }
  895.  
  896.     return $gOptionBoxCloseBtn;
  897. }
  898.  
  899. //
  900. //  Procedure Name:
  901. //      getOptionBoxSaveBtn
  902. //
  903. //  Description:
  904. //      Return the name of the option box's 'Save' button.
  905. //
  906. //  Input Arguments: 
  907. //      None.
  908. //
  909. //  Return Value:
  910. //      The name of the option box's 'Save' button.
  911. //
  912. global proc string getOptionBoxSaveBtn() {
  913.  
  914.     //    Global variables...
  915.     //
  916.     global string $gOptionBoxSaveBtn;
  917.  
  918.     if (`button -exists $gOptionBoxSaveBtn`) {
  919.     } else {
  920.         error "Option Box window does not exist.";
  921.     }
  922.  
  923.     return $gOptionBoxSaveBtn;
  924. }
  925.  
  926.